
/**
 * 动态创建信息
 */
(function($) {
	$.fn.extend({
		createInfo: function(options) {
			var settings = $.extend({
				valueWidth:250, //默认控件宽度 
				labelWidth:90, //默认标签宽度 
				space:40, //默认间隔宽度
				rightToken:'：', //默认标签后缀 
				labelAlign:'left', //默认标签对齐方式
				align:'left', //默认控件对齐方式
				fields: []
			}, options);
			return this.each(function() {
				var target = $(this).addClass('l-info');
				var currul = ['<ul>'];
				for(var x in settings.fields){
					var field = settings.fields[x];
					if(field.group){
						if(currul.length > 1){
							currul.push('</ul>');
							target.append(currul.join(' '));
							currul = ['<ul>'];
						}
						$('<div/>',{
							'class': 'l-group l-group-hasicon',
							'html':'<img src="'+field.groupicon+'"/><span>'+ field.group +'</span>'
						}).appendTo(target);
						
					}
					if(field.newline){
						if(currul.length > 1){
							currul.push('</ul>');
							target.append(currul.join(' '));
							currul = ['<ul>'];
						}
					}
					var width = field.width?field.width:settings.valueWidth;
					if(field.type == 'img'){
						currul.push('<li style="width:'+settings.labelWidth+'px;text-align:'+ settings.labelAlign +';">'+ field.display + settings.rightToken +'</li>');
						currul.push('<li style="width:'+width+'px;text-align:'+ settings.align +';">');
						currul.push('<a href="'+ field.value +'" target="_blank"><img class="image" border="0" src="'+ field.value +'"/></a></li>');
						currul.push('<li style="width:'+settings.space+'px;"></li>');
					}else{
						currul.push('<li style="width:'+settings.labelWidth+'px;text-align:'+ settings.labelAlign +';">'+ field.display + settings.rightToken +'</li>');
						currul.push('<li style="width:'+width+'px;text-align:'+ settings.align +';">'+ field.value +'</li>');
						currul.push('<li style="width:'+settings.space+'px;"></li>');
					}
					if(x == settings.fields.length - 1){
						if(currul.length > 1){
							currul.push('</ul>');
							target.append(currul.join(' '));
							currul = ['<ul>'];
						}
					}
				}
			});
		}
	});
})(jQuery);


/*(function($) {
	$.fn.extend({
		ThreeArea: function(options) {
			var settings = $.extend({
				contextpath:'',//上下文
				province: null, //省份选择器
				city: null, //市选择器
				country: null,//县选择器
				onchange: function(code){},
				value:'0'//初始值
			}, options);
			return this.each(function() {
				
			});
		}
	});
})(jQuery);*/